﻿@using Pyramid.Models
@using Pyramid.Mvc.Html
@model List<StaffSalaryDetail>
@{
	var parts = (List<SalaryPart>) ViewBag.SalaryParts;
	var year = (int) ViewBag.Year;
	var date = DateTime.Now;
	var groups = Model.GroupBy(x => x.Master);
}


<div class="pageHeader">
	@using (Html.BeginForm("MySalary", "StaffSalary", FormMethod.Post, new {onsubmit = "return navTabSearch(this);"}))
	{
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>年份：</td>
					<td>@Html.DropDownListForRange("year", 2010, date.Year, year)</td>
					<td>
						<div class="buttonActive">
							<div class="buttonContent">
								<button type="submit">查询</button>
							</div>
						</div>
					</td>
				</tr>
			</table>
		</div>
	}
</div>
<div class="pageContent">
	<table class="table" width="100%" layouth="110">
		<thead>
			<tr>
				<th>月份</th>
				@foreach (var part in parts)
				{
					<th>@part.VariableName</th>
					<th>@part.Name</th>
				}
				<th>总计</th>
			</tr>
		</thead>
		<tbody>
			@foreach (var g in groups)
			{
				<tr>
					<td>@string.Format("{0}年{1}月", g.Key.Year, g.Key.Month)</td>
					@foreach (var p in parts)
					{
						var d = g.FirstOrDefault(x => x.PartId == p.Id);
						<td>@(d == null ? "" : d.SettingDetail.Value.ToString(p.DisplayFormat))</td>
						<td>@(d == null ? "" : d.Value.ToString("C"))</td>
					}
					<td>@g.Sum(x => x.Value).ToString("C")</td>
				</tr>
			}
		</tbody>
	</table>
</div>
